package singleton;

public class SingleEnumTest {
    public static void main(String[] args) {
        SingleEnum2 test1 = SingleEnum2.TEST_1;
        SingleEnum2 test2 = SingleEnum2.TEST_1;
        System.out.println(test1);
        System.out.println(test2);
        System.out.println(test1 == test2);
    }
}
// 饿汉式
enum SingleEnum{
    INSTANCE;
}
enum SingleEnum2{
    TEST_1("xiangjiao",24);
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    SingleEnum2(String name, int age) {
        this.name = name;
        this.age = age;
    }

    SingleEnum2() {
    }
}